package org.swift.mashup.engine.model;

import java.util.Collection;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

public abstract class XMLActivity implements Activity{
	
	private final Collection<? extends Parameter> params;
	private final Map<String, String> namespaces;
	private String workingDirectory;
		
	/**
	 * size in bytes of the maximum length of the object before we start dumping stuff to memory;
	 */
	protected final static int DUMPTOMEMORYSIZE = 10485760;
	
	protected final static ActivityContext NULL_CONTEXT = new ByteArrayActivityContext("<null/>");
	
	public XMLActivity(Collection<? extends Parameter> params,
			Map<String, String> namespaces) {
		this.params = params;
		this.namespaces = namespaces;
	}

	protected Collection<? extends Parameter> getParams() {
		return params;
	}

	protected Map<String, String> getNamespaces() {
		return namespaces;
	}

	public void setWorkingDirectory(String workingDirectory) {
		this.workingDirectory = workingDirectory;		
	}
	
	public String getWorkingDirectory() {
		return this.workingDirectory;
	}
	
	protected boolean doPersistent(long size) {
		return (size > DUMPTOMEMORYSIZE && !StringUtils.isEmpty(workingDirectory));
	}
}
